package com.max.xihu.patterns.factory;

/**
 * @Author: Max
 * @Date: 2020-09-03 22:25
 * @Description:
 */
public class ConcreteCreator extends AbstractFactory {
    @Override
    public <T extends AbstractProduct> T createProduct(Class<T> c) {

        AbstractProduct product = null;

        //通过反射获取产品实例
        try {
            product = (AbstractProduct) Class.forName(c.getName()).newInstance();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return (T) product;
    }
}
